package cn.java79.quiz.entity;

import cn.java79.quiz.pojo.Section;
import cn.java79.quiz.util.StrUtil;

import java.util.Date;

public class Questions {
    private Long id;

    private String questionanalysis;

    private String title;

    private Short difficulty;

    private String answers="";

    private Short weight;

    private Short degree;

    private Date createdate;

    private String content;

    private Long examskillid;

    private byte[] picture;

    //显示知识点名称
    //private String sectionname;

    private Section sect;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Section getSect() {
        return sect;
    }

    public void setSect(Section sect) {
        this.sect = sect;
    }

    public String getQuestionanalysis() {
        return questionanalysis;
    }

    public void setQuestionanalysis(String questionanalysis) {
        this.questionanalysis = questionanalysis == null ? null : questionanalysis.trim();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title == null ? null : title.trim();
    }

    public Short getDifficulty() {
        return difficulty;
    }

    public void setDifficulty(Short difficulty) {
        this.difficulty = difficulty;
    }

    public String getAnswers() {
        return answers;
    }
    public String getAnswerStr() {
        char[] chars = answers.toCharArray();
        final String ch="ABCDEFG";
        String str="";
        for(char c:chars)
        {//去掉多选中的逗号
            if(c==',')
                continue;
            str+=ch.charAt(c-'0');
        }
        return str;
    }

    public void setAnswers(String answers) {
        this.answers = answers == null ? null : answers.trim();
    }

    public Short getWeight() {
        return weight;
    }

    public void setWeight(Short weight) {
        this.weight = weight;
    }

    public Short getDegree() {
        return degree;
    }

    public void setDegree(Short degree) {
        this.degree = degree;
    }

    public Date getCreatedate() {
        return createdate;
    }

    public void setCreatedate(Date createdate) {
        this.createdate = createdate;
    }

    public String getContent() {
        return content;
    }
    public String[] getOptions() {
        if(content==null)return new String[0];
        String[] split = content.trim().split("@!@");
        for(int i=0;i<split.length;i++){
            split[i]=split[i].substring(split[i].indexOf(':')+1);
        }
        return split;
    }

//    public String getSectionname() {
//        return sectionname;
//    }
//
//    public void setSectionname(String sectionname) {
//        this.sectionname = sectionname;
//    }

    public void setContent(String content) {
        this.content = content == null ? null : content.trim();
    }

    public Long getExamskillid() {
        return examskillid;
    }

    public void setExamskillid(Long examskillid) {
        this.examskillid = examskillid;
    }

    public byte[] getPicture() {
        return picture;
    }

    public void setPicture(byte[] picture) {
        this.picture = picture;
    }

    public String getPictBase64(){
        return "data:image/png;base64,"+StrUtil.toBase64(this.picture);
    }
}